-- 1.lua
-- Created by zouyb Jun/26/2015
-- 野猪BUFF光效

return {
    onAppear = function(monster)    
		-- 野猪出现时，场上所有的野猪（包含新出的）, 播放"属性增益"光效

		-- 当前关卡
		local uiCurLevel = UIDungeonMgr.getCurLevel();
		
	    -- 当前怪物的基类ID
		local baseClassId = monster:query("base_class_id");

		-- 获取其他所有野猪
        local openMonsterGrids = UIDungeonMgr:getCurLevel():getOpenMonsterGrids();
        local count = 0;
        for i = 1, #openMonsterGrids do
            local monsterGrid = openMonsterGrids[i];
            if monsterGrid.gridData.monster:query("base_class_id") == baseClassId then
                count = count + 1;
            end
        end
            
        if count >= 2 then
            for i = 1, #openMonsterGrids do
    			local monsterGrid = openMonsterGrids[i];
    			if monsterGrid.gridData.monster:query("base_class_id") == baseClassId then
    				playAddBuffEffect(monsterGrid, BUFF_TYPE_ATTACK);
    			end
    		end
    	end	
    end,

    onDie = function(monster)    
		-- 每死亡一只野猪，其他野猪播放“属性减益”光效

		-- 当前关卡
		local uiCurLevel = UIDungeonMgr.getCurLevel();
		
		-- 当前怪物的基类ID
		local baseClassId = monster:query("base_class_id");

		-- 获取其他所有野猪
        local openMonsterGrids = UIDungeonMgr:getCurLevel():getOpenMonsterGrids();
        for i = 1, #openMonsterGrids do
			local monsterGrid = openMonsterGrids[i];
            if monsterGrid.gridData.monster ~= monster and monsterGrid.gridData.monster:query("base_class_id") == baseClassId then
                playAddDeBuffEffect(monsterGrid, DEBUFF_TYPE_ATTACK);
			end
		end
    end,
};